//////////////////////////////////////////////////////////////////////////
#include <RocketLua/RocketLua.hpp>


using namespace Rocket::Core::Lua;


//////////////////////////////////////////////////////////////////////////
Plugin::Plugin( lua_State* state )
	:	mpState( state )
{
	assert( mpState );
	_Register();
}


Plugin::~Plugin()
{
}


void Plugin::Initialize( lua_State* state )
{
	Rocket::Core::RegisterPlugin( new Plugin( state ) );
}


void Plugin::_Register()
{
	Vector2i::Register( mpState );
	Vector2f::Register( mpState );
	Colorb::Register( mpState );
	Colorf::Register( mpState );
	LuaEvent::Register( mpState );
	LuaElement::Register( mpState );
	LuaDocument::Register( mpState );
	LuaContext::Register( mpState );
}


int Plugin::GetEventClasses()
{
	return EVT_BASIC;
}


void Plugin::OnInitialise()
{
	Rocket::Core::Factory::RegisterElementInstancer( "body", new LuaDocumentInstancer( mpState ) )->RemoveReference();
	Rocket::Core::Factory::RegisterEventListenerInstancer( new LuaEventListenerInstancer( mpState ) )->RemoveReference();
}


void Plugin::OnShutdown()
{
	delete this;
}
